# 给定一个 24 小时制（小时:分钟 "HH:MM"）的时间列表，找出列表中任意两个时间的最小时间差并以分钟数表示。 
# 
#  
# 
#  示例 1： 
# 
#  
# 输入：timePoints = ["23:59","00:00"]
# 输出：1
#  
# 
#  示例 2： 
# 
#  
# 输入：timePoints = ["00:00","23:59","00:00"]
# 输出：0
#  
# 
#  
# 
#  提示： 
# 
#  
#  2 <= timePoints.length <= 2 * 10⁴ 
#  timePoints[i] 格式为 "HH:MM" 
#  
# 
#  Related Topics 数组 数学 字符串 排序 👍 267 👎 0
from typing import List


# leetcode submit region begin(Prohibit modification and deletion)
class Solution:
    def findMinDifference(self, timePoints: List[str]) -> int:
        t = []
        for time in timePoints:
            h = time.split(':')[0]
            m = time.split(':')[1]
            temp = int(h) * 60 + int(m)
            # 对于每个数，有一个当天的正常时间（正数），也有一个负数
            t.append(temp)
            t.append(temp - 1440)
        t.sort()
        mint = 2881
        for i in range(1, len(t)):
            mint = min(mint, abs(t[i] - t[i - 1]))
        return mint


# leetcode submit region end(Prohibit modification and deletion)
print(Solution().findMinDifference(timePoints=["02:39", "10:26", "21:43"]))
# 测试用例:["02:39","10:26","21:43"]
# 	测试结果:467
# 	期望结果:296
